#include <cppunit/testassert.h>
#include <algorithm>
#include "TestPath.h"
#include "Path.h"
#include "Location.h"
#include "direction.h"
#include "map.h"
#include "stream_utils.h"

CPPUNIT_TEST_SUITE_REGISTRATION( TestPath );

TestPath::TestPath()
{
    //ctor
}

TestPath::~TestPath()
{
    //dtor
}

void TestPath::PathFound()
{
    Location from(5,5);
    Location to(5,8);

    t_path path;
    t_path expected;
    expected.push_back(EAST);
    expected.push_back(EAST);

    Path::Find(from, to, path);

    bool res = std::equal(path.begin(), path.end(), expected.begin());


    CPPUNIT_ASSERT_MESSAGE( "List size mismatch", path.size() == expected.size());
    CPPUNIT_ASSERT( true==res);
}

void TestPath::h1()
{
    CPPUNIT_ASSERT_EQUAL( 6, Path::h(Location(0,0), Location(1,5)));
    CPPUNIT_ASSERT_EQUAL( 6, Path::h(Location(1,5), Location(0,0)));
    CPPUNIT_ASSERT_EQUAL( 6, Path::h(Location(5,1), Location(0,0)));

    CPPUNIT_ASSERT_EQUAL( Path::h(Location(45,-7), Location(120,15)), Path::h(Location(120,15), Location(45,-7)));
}

void TestPath::ATest()
{
    Map m(3,4);
    m.OnDiscovered(1,1,'.');
    //std::cout << std::endl;
    //std::cout<<m;
  //  A a(Location(10,10), Location(12,10));
    //a.find();
}
